package com.bioroadlab.service;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bioroadlab.pojo.Sysuser;

@Service
@Transactional
public class SysuserService extends BaseService {

	public Sysuser findByUserNameAndPassword(Sysuser sysuser) {
		return getSysuserDao().findUserByNameAndPassword(sysuser);
	}

	public void saveNewSysuser(Sysuser sysuser) {
		getSysuserDao().save(sysuser);
	}

	public Sysuser findByUserName(String sysusername) {
		return getSysuserDao().findUserByName(sysusername);
	}

	public void updateSysuser(Sysuser user, String newPassword) {
		user.setPassword(DigestUtils.md5Hex(DigestUtils.md5Hex(newPassword)));
		getSysuserDao().updateSysuser(user);
	}

}
